import Mock from 'mockjs';
const count = 100;
let advertisinglist =[]; //广告配置
let contentList = []; //内容配置
let platformShow= []; //组件列表集合
let assemblyList = [];// 组件列表
let assemblyManageList = [];// 组建管理
let pageLayoutList = [];// 页面布局
let appTemplateList = [];// app\小程序模板
for (let i = 0; i < count; i++) {
    advertisinglist.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        'no': 'NO1000' + i,
        'name': '@word',
        'type': '2019-12-0' + i,
        'message': '这里是描述' + i,
        'actions|1': [
            [{
                name: 'Delete',
                label: '删除'
            },{
                name: 'Edit',
                label: '编辑',
                handleType: 'link'
            },
            ]
        ]
    }))
    contentList.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        'no': 'NO1000' + i,
        'name': '@word',
        'type': '2019-12-0' + i,
        'message': '这里是描述' + i,
        'actions|1': [
            [{
                name: 'Delete',
                label: '删除'
            }
                // {
                //     name: 'Delete',
                //     label: '删除'
                // }, {
                //     name: 'Register',
                //     label: '注册',
                //     handleType: 'link'
                // }
            ]
        ]
    }))
    platformShow.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        'no': 'NO1000' + i,
        'name': '@word',
        'type': '分类' + i,
        'message': '这里是描述' + i,
        'actions|1': [
            [{
                name: 'AdvertisingShow',
                label: '广告配置',
                handleType: 'link'
            },{
                name: 'ContentShow',
                label: '内容配置',
                handleType: 'link'
            },
                // {
                //     name: 'Delete',
                //     label: '删除'
                // }, {
                //     name: 'Register',
                //     label: '注册',
                //     handleType: 'link'
                // }
            ]
        ]
    }))
    assemblyList.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        'no': 'NO1000' + i,
        'name': '@word',
        'type': '分类' + i,
        'isUse|1': ['已启用', '已禁用'],
        'actions|1': [
            [{
                 name: 'Show',
                 label: '查看组件',
                 handleType: 'link'
             },
             // {
             //     name: 'Delete',
             //     label: '删除'
             // }, {
             //     name: 'Register',
             //     label: '注册',
             //     handleType: 'link'
             // }
            ]
        ]
    }))
    assemblyManageList.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        'name': '@word',
        'note': '@word',
        'actions|1': [
            [{
                name: 'Edit',
                label: '编辑',
                handleType: 'link'
            }, {
                name: 'Delete',
                label: '删除'
            }]
        ]
    }))
    pageLayoutList.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        'name': '@word',
        'no': 'NO10000' + i,
        'type': '默认类型',
        'actions|1': [
            [{
                name: 'Edit',
                label: '编辑',
                handleType: 'link'
            }, {
                name: 'Delete',
                label: '删除'
            }]
        ]
    }))
    appTemplateList.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        'name': '@word',
        'actions|1': [
            [{
                name: 'Edit',
                label: '编辑',
                handleType: 'link'
            }, {
                name: 'Use',
                label: '套用'
            }]
        ]
    }))
}

export default [
    {
        path: '/api/getAssemblyList',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...assemblyList].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }, {
        path: '/api/getPlatformShow',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...platformShow].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },{
        path: '/api/getAdvertisinglist',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...advertisinglist].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },{
        path: '/api/getContentList',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...contentList].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }, {
        path: '/api/getAssembly',
        method: 'get',
        handle ({ body }) {
            if (body.uuid) {
                let memberInfo = {};
                for (let i = 0; i < assemblyList.length; i++) {
                    if (Number(body.uuid) === assemblyList[i].uuid) {
                        memberInfo = assemblyList[i];
                        break;
                    }
                }
                return {
                    code: 0,
                    msg: '',
                    data: {
                        data: memberInfo,
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/addAssembly',
        method: 'get',
        handle ({ body }) {
            if (body.userName) {
                assemblyList.unshift(body.formData);
                return {
                    code: 0,
                    msg: '',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }, {
        path: '/api/getPageLayoutList',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...pageLayoutList].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }, {
        path: '/api/getPageLayout',
        method: 'get',
        handle ({ body }) {
            if (body.uuid) {
                let memberInfo = {};
                for (let i = 0; i < pageLayoutList.length; i++) {
                    if (Number(body.uuid) === pageLayoutList[i].uuid) {
                        memberInfo = pageLayoutList[i];
                        break;
                    }
                }
                return {
                    code: 0,
                    msg: '',
                    data: {
                        data: memberInfo,
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/addPageLayout',
        method: 'get',
        handle ({ body }) {
            if (body.userName) {
                pageLayoutList.unshift(body.formData);
                return {
                    code: 0,
                    msg: '',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/getAssemblyManageList',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...assemblyManageList].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }, {
        path: '/api/getAssemblyManage',
        method: 'get',
        handle ({ body }) {
            if (body.uuid) {
                let memberInfo = {};
                for (let i = 0; i < assemblyManageList.length; i++) {
                    if (Number(body.uuid) === assemblyManageList[i].uuid) {
                        memberInfo = assemblyManageList[i];
                        break;
                    }
                }
                return {
                    code: 0,
                    msg: '',
                    data: {
                        data: memberInfo,
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/addAssemblyManage',
        method: 'get',
        handle ({ body }) {
            if (body.userName) {
                assemblyManageList.unshift(body.formData);
                return {
                    code: 0,
                    msg: '',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/getAppTemplateList',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...appTemplateList].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }, {
        path: '/api/getAppTemplate',
        method: 'get',
        handle ({ body }) {
            if (body.uuid) {
                let memberInfo = {};
                for (let i = 0; i < appTemplateList.length; i++) {
                    if (Number(body.uuid) === appTemplateList[i].uuid) {
                        memberInfo = appTemplateList[i];
                        break;
                    }
                }
                return {
                    code: 0,
                    msg: '',
                    data: {
                        data: memberInfo,
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/addAppTemplate',
        method: 'get',
        handle ({ body }) {
            if (body.userName) {
                appTemplateList.unshift(body.formData);
                return {
                    code: 0,
                    msg: '',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }

]
